package C9_7_IntroduceNullObject;

/**
 * @author xugang1
 * @updated 2022/7/25
 * @description 引入Null对象
 */


public class IntroduceNullObject {
    Site site;
    Customer customer = site.getCustomer();


    /**
     * 重构第一步
     */
    BillingPlan plan;
    if(customer.isNull()) plan =BillingPlan.basic();
    else plan=customer.getPlan();

    String customerName;
    if(customer.isNull()) customerName ="occupant";
    else customerName=customer.getName();

    int weeksDelinquent;
    if(customer.isNull()) weeksDelinquent =0;
    else weeksDelinquent=customer.getHistory().getWeeksDelinquentInLastYear();


    /**
     * 重构第二步
     */
    BillingPlan plan=customer.getPlan();

    String customerName=customer.getName();

    int weeksDelinquent=customer.getHistory().getWeeksDelinquentInLastYear();
}